﻿<%@ Page Language="C#" MasterPageFile="~/Theme/Stander/Stander.master" AutoEventWireup="true" CodeFile="MediaAdvances.aspx.cs" Inherits="Media_MediaAdvances" Title="Untitled Page" %>
<%@ Import Namespace="Active.Core" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p><a href='Media.aspx?id=<%= Request.QueryString["id"] %>' 
     title="查看媒介信息">[<%= GetMedia().Name %>]</a>
    的剩余预付款: <%= GetMedia().Advance.ToString("c") %></p>
<h2>添加预存款</h2>
<asp:DetailsView ID="AdvanceDetailsView" DefaultMode="Insert" 
    runat="server" AutoGenerateRows="False" DataSourceID="AdvanceInfoDataSource">
    <Fields>
        <asp:TemplateField HeaderText="金额：">
            <InsertItemTemplate>
                <asp:TextBox ID="txtAdvance" runat="server" ValidationGroup="MediaAdvance" 
                    Text='<%# Bind("PayValue") %>'>0</asp:TextBox>
                <asp:RequiredFieldValidator
                    ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtAdvance" Display="Dynamic"
                    ErrorMessage="不能为空" ValidationGroup="MediaAdvance"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator
                        ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtAdvance"
                        Display="Dynamic" ErrorMessage="输入不合法" ValidationExpression="^-?[1-9]+\d*(\.\d+)?$"
                        ValidationGroup="MediaAdvance"></asp:RegularExpressionValidator>
            </InsertItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="备注：">
            <InsertItemTemplate>
                <asp:TextBox ID="txtDescription" TextMode="MultiLine" Rows="3" 
                    runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                <asp:RequiredFieldValidator
                    ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtDescription"
                    ErrorMessage="不能为空" ValidationGroup="MediaAdvance"></asp:RequiredFieldValidator>
            </InsertItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField ShowHeader="False">
            <InsertItemTemplate>
                <asp:Button ID="Button1" runat="server" CausesValidation="True" CommandName="Insert"
                    ValidationGroup="MediaAdvance" 
                    OnClientClick='javascript:submitConfirm("添加后不能修改的, 确定添加预付款吗？");'
                    Text="添加" />
            </InsertItemTemplate>
        </asp:TemplateField>
    </Fields>
</asp:DetailsView>
<csla:CslaDataSource ID="AdvanceInfoDataSource" runat="server" 
    TypeSupportsPaging="False" TypeSupportsSorting="False" 
    OnInsertObject="AdvanceInfoDataSource_InsertObject">
</csla:CslaDataSource>
<h2>历史记录:</h2>
<asp:GridView ID="gvAdvances" runat="server" AutoGenerateColumns="False" CssClass="normal mouseOver"
    DataSourceID="AdvancesDataSource">
    <Columns>
        <asp:TemplateField HeaderText="交易金额" ItemStyle-CssClass="right">
        <ItemTemplate>
            <asp:Label ID="lblAdvance" runat="server" Text='<%#Bind("PayValue", "{0:c}") %>'></asp:Label>
        </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="提交时间">
            <ItemTemplate>
                <asp:Label ID="lblSubmitDate" runat="server" Text='<%# Bind("SubmitDate", "{0:yyyy-MM-dd hh:mm}") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="提交者">
            <ItemTemplate>
                <asp:HyperLink ID="HyperLink1" runat="server" 
                    NavigateUrl='<%# string.Format("~/Users/User.aspx?User={0}", Eval("SubmitUser")) %>'><%# Eval("SubmitUser")%></asp:HyperLink>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="备注" ItemStyle-CssClass="left">
            <ItemTemplate>
                <asp:Label ID="lblDescription" runat="server" Text='<%#Bind("Description") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    <EmptyDataTemplate>
        暂无预存款记录.
    </EmptyDataTemplate>
</asp:GridView>
<csla:CslaDataSource ID="AdvancesDataSource" runat="server" 
    TypeName="Active.Core.AdvanceList, Active.Core" OnSelectObject="AdvancesDataSource_SelectObject"
    TypeSupportsSorting="False">
</csla:CslaDataSource>
<webdiyer:aspnetpager id="aspnetPager" runat="server" OnPageChanged="aspnetPager_PageChanged"
    PageSize="15"></webdiyer:aspnetpager>
</asp:Content>

